package com.examples.varlength;

public class VariableLength {

	public int sum(int... a) {
		int sum = 0;
		for (int i = 0; i < a.length; i++) {
			sum += a[i];
		}
		return sum;
	}

	public static void main(String[] args) {

		// Variable Length
		System.out.println(" \nVariable Length");
		VariableLength var = new VariableLength();
		System.out.println("var.sum(3,4)" + var.sum(3, 4));
		System.out.println("var.sum(3,4,6,8)" + var.sum(3, 4, 6, 8));
		System.out.println("var.sum(3)" + var.sum(3));

	}
}
